{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "5c62de1c-f064-41b0-9478-13e40d63c22b",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "F:\\programData\\conda\\env\\ChatGLM2-6B\\lib\\site-packages\\numpy\\_distributor_init.py:30: UserWarning: loaded more than 1 DLL from .libs:\n",
      "F:\\programData\\conda\\env\\ChatGLM2-6B\\lib\\site-packages\\numpy\\.libs\\libopenblas.FB5AE2TYXYH2IJRDKGDGQ3XBKLKTF43H.gfortran-win_amd64.dll\n",
      "F:\\programData\\conda\\env\\ChatGLM2-6B\\lib\\site-packages\\numpy\\.libs\\libopenblas64__v0.3.23-246-g3d31191b-gcc_10_3_0.dll\n",
      "  warnings.warn(\"loaded more than 1 DLL from .libs:\"\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sequential(\n",
      "  (0): LazyLinear(in_features=0, out_features=256, bias=True)\n",
      "  (1): ReLU()\n",
      "  (2): Linear(in_features=256, out_features=10, bias=True)\n",
      ")\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "F:\\programData\\conda\\env\\ChatGLM2-6B\\lib\\site-packages\\torch\\nn\\modules\\lazy.py:180: UserWarning: Lazy modules are a new feature under heavy development so changes to the API or functionality can happen at any moment.\n",
      "  warnings.warn('Lazy modules are a new feature under heavy development '\n"
     ]
    }
   ],
   "source": [
    "import torch\n",
    "from torch import nn\n",
    "net = nn.Sequential(nn.LazyLinear(256),nn.ReLU(),nn.Linear(256,10))\n",
    "print(net)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a8161776-a1e8-4df9-95af-33391077b50e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[OrderedDict([('weight', <UninitializedParameter>),\n",
       "              ('bias', <UninitializedParameter>)]),\n",
       " OrderedDict(),\n",
       " OrderedDict([('weight',\n",
       "               tensor([[-0.0023, -0.0566,  0.0407,  ..., -0.0563,  0.0205, -0.0145],\n",
       "                       [ 0.0479, -0.0451, -0.0145,  ...,  0.0516, -0.0037,  0.0088],\n",
       "                       [ 0.0125, -0.0382,  0.0600,  ..., -0.0138,  0.0567, -0.0440],\n",
       "                       ...,\n",
       "                       [-0.0217,  0.0002, -0.0163,  ...,  0.0499, -0.0522,  0.0560],\n",
       "                       [ 0.0231,  0.0612,  0.0597,  ..., -0.0445, -0.0031,  0.0096],\n",
       "                       [ 0.0129, -0.0038,  0.0371,  ...,  0.0274,  0.0079,  0.0511]])),\n",
       "              ('bias',\n",
       "               tensor([ 0.0181,  0.0042, -0.0021,  0.0345, -0.0336,  0.0587,  0.0451,  0.0247,\n",
       "                        0.0251,  0.0081]))])]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[net[i].state_dict() for i in range(len(net))]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "8245c444-52b2-4d4a-8db0-6999ac7f99a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[-1.5022e+36, -6.7023e+36,  5.8205e+36, -2.8856e+36,  1.8594e+35,\n",
       "          3.8865e+36, -9.3596e+36,  1.1447e+36,  4.5275e+36,  8.6368e+35],\n",
       "        [-8.0457e+36, -1.5462e+37,  3.3207e+36,  2.6372e+36, -2.0282e+36,\n",
       "          4.6078e+36, -3.1301e+36,  7.8631e+36, -8.9157e+34, -1.8980e+36]],\n",
       "       grad_fn=<AddmmBackward0>)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "low = torch.finfo(torch.float32).min/10\n",
    "high = torch.finfo(torch.float32).max/10\n",
    "\n",
    "x = torch.zeros([2,20],dtype=torch.float32).uniform_(low,high)\n",
    "net(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a207a1d4-1998-4a2d-91c8-edd9c0261e1f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sequential(\n",
      "  (0): Linear(in_features=20, out_features=256, bias=True)\n",
      "  (1): ReLU()\n",
      "  (2): Linear(in_features=256, out_features=10, bias=True)\n",
      ")\n"
     ]
    }
   ],
   "source": [
    "print(net)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.17"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
